<div class="col-md-12">
  <div class="page-header">
    <h1 class="default">所有博客</h1>
  </div>
  <table class="table table-hover">
    <thead>
      <tr>
        <th><%= t "Title"  %> <%=  link_to "sort", blogs_path(sort: "title")  %></th>
        <th><%= t "Content" %>  <%=  link_to "sort", blogs_path(sort: "content") %></th>
        <th><%= t "Time" %> <%=  link_to "sort", blogs_path(sort: "time") %></th>
        <th>Visible</th>
        <th>Username</th>
        <th colspan="3"></th>
      </tr>
    </thead>

    <tbody>
      <% @blogs.each do |blog| %>
        <tr>
          <td><%= blog.title %></td>
          <td><%= blog.content %></td>
          <td><%= blog.time %></td>
          <td><%= status_tag(blog.visible)%></td>
          <td><%= blog.user.email if blog.user!=nil %></td>
          <td><%= link_to 'Show', blog, :class=>"btn btn-default btn-sm"%></td>
          <% if blog.editable_by?(current_devise_user) %>
            <td><%= link_to 'Edit', edit_blog_path(blog), :class=>"btn btn-default btn-sm"%></td>
            <td><%= link_to 'Destroy', blog, method: :delete, data: { confirm: 'Are you sure?' } , :class=>"btn btn-default btn-sm"%></td>
          <% else %>
            <td></td>
            <td></td>
          <% end %>
        </tr>
      <% end %>
    </tbody>
  </table>

  <br>
  <%# console # 开启界面console, 感觉还是后台的rails c来的更爽，操作更方便一些%>

  <%= link_to 'New Blog', new_blog_path, class: "btn btn-success" %>
</div>